<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core">

	<h:outputText rendered="#{areaBean.saveImportarAreaState}">
		<div class="innerTitle">Importação de Áreas</div>
	</h:outputText>

	<h:inputHidden value="#{areaBean.entity.id}" rendered="#{areaBean.updateState}"/>

	<table>
	 	<tr>

	 		<td style="padding-right: 10px;">
				<h:outputLabel value="Descrição da área:" styleClass="padding-right:10px"/><br/>
				<h:inputText id="nomeArea" value="#{areaBean.entity.nome}" required="true" maxlength="50" size="22">
					<f:validateLength maximum="50" />
					<a4j:support event="onchange" action="#{areaBean.populate}" reRender="nomeArea"/>
				</h:inputText>
				<rich:message errorClass="error" for="nomeArea"/>	
			</td>

			<td>
				<h:outputLabel value="Tipo de Área" styleClass="padding-right:10px"/><br/>
				<h:selectOneMenu id="tipoArea" value="#{areaBean.entity.tipo}" required="true" immediate="true" styleClass="filesRoute" style="width:120px">
					<f:selectItems value="#{areaBean.tiposArea}"/>
					<a4j:support event="onchange" action="#{areaBean.populate}" reRender="nomeArea"/>
				</h:selectOneMenu>
				<rich:message errorClass="error" for="tipoArea" />	
			</td>
	 	</tr>

	</table>
	<br/>

	<rich:tabPanel switchType="client" immediate="true">

		<rich:tab label="Importar Área" id="cadastroArea" reRender="nomeArea">

			<h:panelGrid columns="5" styleClass="crud" columnClasses="label">

				<rich:fileUpload validatorMessage="OK" fileUploadListener="#{areaBean.saveImportArea}" immediate="false" acceptedTypes="txt, xml, kml"
	            maxFilesQuantity="1" clearControlLabel="Limpar" clearAllControlLabel="Limpar Todos" uploadControlLabel="Carregar"
	            addControlLabel="Carregar Arquivo" doneLabel="Arquivo Enviado!" style="height: 50px;">
					<f:facet name="label">
						<h:outputText value="{_KB}KB de {KB}KB enviados --- {mm}:{ss}"/>
	        		</f:facet>
					<a4j:support event="oncomplete" action="#{areaBean.populate}" reRender="popup"/>
				</rich:fileUpload>

			</h:panelGrid>

		</rich:tab>

	</rich:tabPanel>

	<a4j:commandButton value="Voltar" type="submit" action="#{areaBean.search}" styleClass="button" immediate="true"  reRender="popup"/>

</ui:composition>